# scripts/downloader.py
import earthaccess
import config


def search_and_download():
    results = earthaccess.search_data(
        short_name="MOD16A2",
        cloud_hosted=True,
        bounding_box=config.BBOX,
        temporal=(config.START_DATE, config.END_DATE)
    )

    print(f"🔍 找到 {len(results)} 个 granule，开始下载至 {config.DOWNLOAD_DIR}")
    earthaccess.download(results, config.DOWNLOAD_DIR)
